import Vue from 'vue'
import Vuex from 'vuex'

import {
  testExercisesHisQuery,
  testExercisesHisDelete,
  testExercisesHisAdd,
  testExercisesHisUpdate,
  testExercisesHisSubmitPaper,
} from '@/api/admin/exam/testExercisesHis'

Vue.use(Vuex)

const state = {}

const getters = {}

const actions = {
  //我的练习增删改查
  async queryTestExercisesHis({ commit }, listQuery) {
    let res = await testExercisesHisQuery({ ...listQuery })
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async delTestExercisesHis({ commit }, row) {
    let res = await testExercisesHisDelete(row.id)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async addTestExercisesHis({ commit }, data) {
    let res = await testExercisesHisAdd(data)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async updateTestExercisesHis({ commit }, data) {
    let res = await testExercisesHisUpdate(data)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async submitPaperTestExercisesHis({ commit }, data) {
    let res = await testExercisesHisSubmitPaper(data)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
}

const mutations = {}

export default {
  state,
  getters,
  actions,
  mutations,
}
